<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="报表名称" prop="name">
        <el-input v-model="queryParams.name" placeholder="请输入报表名称" clearable style="width: 240px"
                  @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">

      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleOpenReport">打开报表页面</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleOpenReport1">打开报表页面1</el-button>
      </el-col>

      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-download" size="mini" @click="handleOpenDrag">打开大屏页面</el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="list" @selection-change="handleSelectionChange"
              :header-cell-style="{textAlign: 'center'}" :cell-style="{textAlign: 'center'}">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="名称" prop="name" />
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList" />



  </div>
</template>

<script>
import {
  listReport
} from "@/api/py/jeecg/report";
export default {
  name: "PyJeecgTest",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 角色表格数据
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,

      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        name: undefined
      },
      // 表单参数
      form: {},

      // 表单校验
      rules: {
        name: [
          { required: true, message: "名称不能为空", trigger: "change" }
        ],
      }




    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 获取信息列表
    getList() {
      this.loading = true;
      listReport(this.queryParams).then(response => {
        let result = response.result;
        this.list = result.records;
        this.total = result.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

    // 打开报表测试
    handleOpenReport() {
      let query = {
        code: "1121399421230862336",
        id: "3f02599004e0224bb10b7618454faa55",
        name: "测试"
      }
      this.$router.push({ path: "/jeecg/report/view", query });
    },

    // 打开报表测试
    handleOpenReport1() {
      let query = {
        code: "1121399421230862336",
        id: "3f02599004e0224bb10b7618454faa55",
        name: "测试"
      }
      this.$router.push({ path: "/jeecg/report/view1", query });
    },

    // 打开大屏测试
    handleOpenDrag(){
      let query = {
        code: "1121395545261953024",
      }
      this.$router.push({ path: "/jeecg/drag/view", query });
    }
  }
};
</script>
